<script type="text/javascript">
    function create_news(){       
        content = tinyMCE.get('news_content').getContent({format : 'raw'});
        re = /<[a-zA-Z\/][^>]*>/ig;
        content = content.replace(re," ");
        re = /&\w+;/ig;
        content = content.replace(re," ");   
        content = content.replace(/\s{2,}/," ");
        //Luu gia tri plain text vao truong an. Sau khi submit ve server, lay gia tri
        //truong an ra de luu vao mot truong du lieu ban ro cua noi dung, phuc vu tim kiem
        
        document.getElementById('news_plaintext').value = content;
        return true;
    }
</script>
<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Thêm tin mới</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <form action="" method="post" enctype="multipart/form-data" onsubmit="return create_news()">
        <input type="hidden" name="news_plaintext" id="news_plaintext" />
        <table class="table_content">
        	<tr>
        		<td class="label"><label for="cat_id">Danh mục</label></td>
        		<td class="label2" colspan="2">
        			<select name="cat_id" id="cat_id" class="input">
        				<?php 
        					$category = new AdminDthink_Model_Category();
        					$listCategory = $category->listVoucher(29);
        					foreach($listCategory as $catValue) :
        				?>
        				<option value="<?php echo $catValue['cat_id']; ?>"><?php echo $catValue['cat_name']; ?></option>
        				<?php 
        					endforeach;
        				?>
        			</select>
        		</td>
        	</tr>
			<tr>
				<td class="label"><?php echo $this->formLabel('news_title', 'Tiêu đề'); ?><span class="msg"> * </span></td>
				<td class="label2"><?php echo $this->formText('news_title', $this->newsTitleValue, array('id' => 'news_title', 'class' => 'input')); ?></td>
				<td><span class="msg"><?php echo $this->errorNewsTitle; ?></span></td>
			</tr>
			<tr>
				<td class="label"><?php echo $this->formLabel('news_image', 'Ảnh'); ?><span class="msg"> * </span></td>
				<td class="label2"><?php echo $this->formFile('news_image', array('id' => 'news_image', 'class' => 'input')); ?></td>
				<td><span class="msg"><?php echo $this->errorNewsImage; ?></span></td>
			</tr>
        </table>
        
        <table class="table_content">
            <tr>
                <td class="label"><?php echo $this->formLabel('news_content', 'Nội dung'); ?><span class="msg"> * </span></td>
            </tr>
            <tr>
                <td><?php echo $this->formTextarea('news_content', $this->newsContentValue, array('id' => 'news_content', 'cols' => '80', 'rows' => '30')); ?></td>
                <td><span class="msg"><?php echo $this->errorNewsContent; ?></span></td>
            </tr>
        </table>
        
        <table class="table_content">
			<tr>
				<td class="label">&nbsp;</td>
				<td colspan="2"><span class="msg"><?php echo $this->error; ?></span></td>
			</tr>
			<tr>
				<td class="label">&nbsp;</td>
				<td colspan="2">
					<input class="button" type="submit" name="submit" value="Tạo mới">
					<input class="button" type="reset" name="reset" value="Nhập lại">
					<a href="<?php echo $this->baseUrl('admin-dthink/news'); ?>" class="button" style="padding-top: 7px;">Quay lại</a>
				</td>
			</tr>
        </table>
    </form>
</div><!-- End .main_content -->  